[ 'method' => "GET", 'header' => "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) PHP-Reader\r\n" ] ]; $context = stream_context_create($options); $xml_content = @file_get_contents($rss_url, false, $context); if ($xml_content === false) { die("Не вдалося завантажити RSS."); } $rss = simplexml_load_string($xml_content); $md_content = "### MAXSITE.ORG\n\n"; foreach ($rss->channel->item as $item) { $title = htmlspecialchars_decode((string)$item->title); $link = (string)$item->link; // Форматування дати: 27-04-2026 15:00 $date = new DateTime($item->pubDate); $formattedDate = $date->format('d-m-Y H:i'); $formattedDate = '' . $formattedDate . ''; $description = (string)$item->description; // Шукаємо тільки URL зображення (jpg, jpeg, png, gif, webp) preg_match('/https?:\/\/[^"\'>]+\.(?:jpg|jpeg|png|gif|webp)/i', $description, $matches); $img_src = $matches[0] ?? ''; // 1. ВИЛУЧЕННЯ тегів

разом із вмістом $description_filtered = preg_replace('/]*>.*?<\/p>/is', '', $description); // 2. Вилучення порожніх або "сміттєвих" пар тегів

$description_filtered = preg_replace('/]*>\s*( )*\s*<\/p>/i', '', $description_filtered); // 3. Очищення від решти HTML-тегів $clean_description = strip_tags($description_filtered); // 4. Очищення від зайвих пробілів $clean_description = trim($clean_description); // Формування блоку за макетом $md_content .= " **[{$title}]({$link})** {$formattedDate}\n\n"; $md_content .= "

\n\n"; if ($img_src) { $md_content .= "
" . "![]({$img_src})" . "
\n\n"; } $md_content .= "
{$clean_description}
\n\n"; $md_content .= "---\n\n"; } // Додавання стилів для адаптивності $md_style = ""; $md_content .= $md_style; // Створюємо директорію Новини RSS, якщо її немає if (!is_dir(__DIR__ . '/Новини RSS')) { mkdir(__DIR__ . '/Новини RSS', 0777, true); } // Збереження результату $filename = 'Новини RSS/MAXSITE.ORG.md'; file_put_contents($filename, $md_content); ?>